package com.maxlen.goods.entity.vo;

import com.maxlen.common.valid.AddValid;
import com.maxlen.common.valid.StatusValue;
import com.maxlen.common.valid.UpdateValid;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.URL;

import javax.validation.constraints.*;

@Data
public class BrandVO {

    /**
     * 品牌id
     */
    @Null(message = "新增操作id必须为空", groups = AddValid.class)
    @NotNull(message = "修改操作id不能为空", groups = UpdateValid.class)
    private Long brandId;

    /**
     * 品牌名
     */
    @NotBlank(message = "品牌名不能为空", groups = AddValid.class)
    @Length(min = 1,message = "品牌名不能为空", groups = UpdateValid.class)
    @Length(max = 10, message = "品牌名不能超过10个字符", groups = {AddValid.class, UpdateValid.class})
    private String name;

    /**
     * 品牌logo地址
     */
    @NotBlank(message = "logo不能能为空", groups = AddValid.class)
    @Length(min = 1,message = "logo不能为空", groups = UpdateValid.class)
    @URL(message = "logo 必须是一个合法的 URL 地址", groups = {AddValid.class, UpdateValid.class})
    private String logo;

    /**
     * 介绍
     */
    @Length(max = 20, message = "介绍不能超过20个字符", groups = {AddValid.class, UpdateValid.class})
    private String descript;

    /**
     * 显示状态[0-不显示；1-显示]
     */
    @NotNull(message = "显示状态不能为空", groups = AddValid.class)
    @StatusValue(val = {0,1},message = "显示状态必须为0或1", groups = {AddValid.class, UpdateValid.class})
    private Integer showStatus;

    /**
     * 检索首字母
     */
    @NotBlank(message = "检索首字母不能为空", groups = AddValid.class)
    @Pattern(regexp = "^[a-zA-Z]$", message = "检索首字母必须是一个字母", groups = {AddValid.class, UpdateValid.class})
    private String firstLetter;

    /**
     * 排序
     */
    @NotNull(message = "排序不能为空", groups = AddValid.class)
    @Min(value = 0, message = "排序必须是一个大于0的整数", groups = {AddValid.class, UpdateValid.class})
    private Integer sort;

}
